package com.ruoyi.project.hcy.administrations.controller;

import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.hcy.administrations.domain.Crew;
import com.ruoyi.project.hcy.administrations.service.ICrewService;
import com.ruoyi.project.system.dept.domain.Dept;
import com.ruoyi.project.system.post.domain.Post;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName ApproveController
 * @Author 金刚芭比
 * @Date 2020/9/17 10:55
 * @Version 1.0
 */
@Controller
@RequestMapping("/hcy/administrations")
public class CrewController extends BaseController {

    private String prefix="hcy/administrations";

    @Autowired
    private ICrewService crewService;
    //跳转到页面
    @GetMapping
    @RequiresPermissions("hcy:administrations:view")
    public String openlog() {
        return prefix+"/administration";
    }
    //条件查询以及分页查询
    @RequiresPermissions("hcy:administrations:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Crew crew)
    {
        startPage();
        List<Crew> list = crewService.selectCrewAll(crew);
        return getDataTable(list);
    }
    //跳转到页面
    @GetMapping("/edit/{crewId}")
    public String edit(@PathVariable("crewId") Long crewId, ModelMap mmap) {
        mmap.put("crew", crewService.selectCrewById(crewId));
        return prefix + "/edit";
    }
    //修改
    @RequiresPermissions("hcy:administrations:edit")
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(@Validated Crew crew) {
        return toAjax(crewService.updateCrewById(crew));
    }






}
